new Vue({
    el:'#userManage',
    data:{
        infoFlag:false,
        infoText:'',
        userName:'',
        createTime:'',
        pageInfo:'',
        styleObj:{
            backgroundColor:"#ff4e00",
            border:"none",
            height:"23px",
            width:"23px",
            color:"white"
        },
        no_bgc:{
            height:"22px",
            width:"22px",
        },
        owner:''
    },
    methods:{
        getUserPage(pageNum,pageSize)
        {
          axios.get('/api/getUserPage',
              {
                  params:{
                      pageNum,pageSize,
                      userName:this.userName,
                      createTime: this.createTime
                  }
              }).then(rs=>{
                  this.pageInfo=rs.data.pageInfo
                  this.owner=rs.data.user
                  console.log(this)
          })
        },
        opera(sign)
        {
            let pageNum=1
            switch(sign)
            {
                case "pre":
                    pageNum=this.pageInfo.hasPreviousPage?this.pageInfo.prePage:1
                    break;
                case "next":
                    pageNum=this.pageInfo.hasNextPage?this.pageInfo.nextPage:this.pageInfo.pages
                    break;
                case "last":
                    pageNum=this.pageInfo.pages
                    break;
            }
            this.getUserPage(pageNum,5)
        },
        //修改用户
        updateUser(loginName)
        {
            window.location=`/api/updateUser.html?loginName=${loginName}`
        },


        //删除用户
        deleteUser(id)
        {
            if(confirm("确认删除该用户吗？"))
            {
                axios.get('/api/deleteUser',
                    {
                        params:{
                            id
                        }
                    }).then(rs=>{
                        if(rs.data.isDelete==="yes")
                        {
                            this.infoFlag=true
                            this.infoText="删除成功"
                        }else{
                            this.infoFlag=true
                            this.infoText="删除失败"
                        }
                })
            }

        },
        closeInfo()
        {
            this.infoFlag=false
            window.location="/api/UserManage.html"
        },
    },
    created()
    {
        this.getUserPage(1,5)
    }
})